<div class="g-doc_join">
	<?php
		if($this->isjoin == 1 || $this->MaxJoinLeft == 0):
	?>
	<div class="sharebox">
		<span class="btn2box" onclick="window.location.href='/game-index?signed_request=<?php echo $this->signed_request;?>'">
		</span>
		<span class="text">
			Share your favourite to fans
		</span>
	</div>
	 <?php
		else:
	 ?>
	 <div class="emailbox">
	<?php
		if(!empty($this->man_obj['email'])) {
	?>
	<form action="" method="post" id="join_form">
		<input type="hidden" name="email" id="email" value="<?php if(isset($this->man_obj['email'])) { echo $this->man_obj['email']; }?>" />
		<input type="hidden" name=""uid"" id="uid" value="<?php echo $this->man_obj['id']; ?>" />
		<input type="hidden" name="signed_request" value="<?php echo $this->signed_request;?>" />
		<div class="btn1box">
			<input type="button" name="submit" value="" class="btn1" id="btn1" />
		</div>
	</form>
	<?php
		} else {
	?>
	<form action="" method="post" id="join_form">
		<div class="einput">
			<font>Email：</font>
			<span>
				<input type="text" name="email" id="email" value="" />
				<input type="hidden" name=""uid"" id="uid" value="<?php echo $this->uid; ?>" />
				<input type="hidden" name="signed_request" value="<?php echo $this->signed_request;?>" />
			</span>
		</div>
		<div class="btn1box">
			<input type="button" name="submit" value="" class="btn1" id="btn1" />
		</div>
	</form>
	<?php } ?>
	</div>
	<?php
		endif;
	?>
	<div class="our_page">Our page: <a target="_blank" href="http://www.facebook.com/goalshop">www.facebook.com/goalshop</a></div>
	<div class="endingtime" id="endingtime">
		
	</div>
	<div class="descriptionbox">
		<span class="s_o">
			Looking for 50 fans to share their favourite jersey with their friends,and these 50 fans can choose 2 pcs of free jerseys in our activity website when your sharing amount reach to 1000.
		</span>
		<span class="s_t">
			Remark:There is another mystery gift for you if you can take some of your jerseys' photos and share your feeling in our facebook.
		</span>
	</div>
	<div class="numberbox">
		<div class="fulldiv">
			<span class="title">&nbsp;</span>
			<?php
				$join = sprintf("%04d", ($this->MaxJoin - $this->MaxJoinLeft));
				$join_arr = str_split($join);
			?>
			<ul>
				<?php foreach ($join_arr as $j_num): ?>
				<li><?php echo $j_num; ?></li>
				<?php endforeach; ?>
			</ul>
			<span>
				<?php
					if($this->MaxJoinLeft == 0)
						echo 'Full';
					else
						echo 'left ' . $this->MaxJoinLeft;
				?>
			</span>
		</div>
		<div class="fulldiv">
			<span class="title">&nbsp;</span>
			<?php
				$likes = sprintf("%04d", ($this->MaxLikes - $this->MaxLikesLeft));
				$likes_arr = str_split($likes);
			?>
			<ul>
				<?php foreach ($likes_arr as $l_num): ?>
				<li><?php echo $l_num; ?></li>
				<?php endforeach; ?>
			</ul>
			<span>
				<?php
					if($this->MaxLikesLeft == 0)
						echo 'Full';
					else
						echo 'left ' . $this->MaxLikesLeft;
				?>
			</span>
		</div>
	</div>
</div>
<script>
$(function(){
	$("#btn1").click(function(){
		var email = $("#email").val();
		var uid = $("#uid").val();
		if(email == '') {
			alert('Sorry, please input the correct email address.');
			return false;
		}
		var exp = new RegExp("^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", "i");
		if (!exp.test(email)) {
			alert('Sorry, please input the correct email address.');
			return false;
		}
		$.ajax({
			type: "POST",
			url: "/game-dojoin",
			data: {email:email,uid:uid},
			success: function(data) {
				if(data == 'ok') {
					window.location.href = '/game-index';
					return false;
				} else {
					alert(data);
					return false;
				}
			}			
		});
	});
});
var beginTime = <?php echo $this->EndingTime; ?>000;
var nowTime = <?php echo time(); ?>000;
var sysSecond = (beginTime - nowTime) / 1000;
var interValObj;
setRemainTime();
function setRemainTime()
{	
	if (sysSecond > 0)
	{
		var second = Math.floor(sysSecond % 60);                
		var minite = Math.floor((sysSecond / 60) % 60);       
		var hour = Math.floor((sysSecond / 3600) % 24);       
		var day = Math.floor((sysSecond / 3600) / 24);       
		if (second < 10)
			second = '0'+second;
		if (minite < 10) 
			minite = '0'+minite;
		if (hour < 10)
			hour = '0'+hour;
		var timeHtml = ""+hour+":"+minite+":";
		if (day >= 0 && day < 10) {
			timeHtml = day + ' days  ' + timeHtml;
		} else if (day > 10) {
			timeHtml = day + ' days  ' + timeHtml;
		}
		
		timeHtml+=second;		
		try
		{
			$("#endingtime").html(timeHtml);
			sysSecond--;
		}
		catch(e){}}
	else
	{window.clearTimeout(interValObj);}
	interValObj = window.setTimeout("setRemainTime()", 1000); 	
}
</script>